package br.com.faculdade.infrastructure.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

/**
 *
 * @author Kirmaier
 */
@Entity
@Table(name = "Lancamento")
//@NamedQueries({@NamedQuery(name = "Lancamento.findAll", query = "SELECT l FROM Lancamento l"), @NamedQuery(name = "Lancamento.findByIdlancamento", query = "SELECT l FROM Lancamento l WHERE l.idlancamento = :idlancamento"), @NamedQuery(name = "Lancamento.findByValortotal", query = "SELECT l FROM Lancamento l WHERE l.valortotal = :valortotal"), @NamedQuery(name = "Lancamento.findByDatalancamento", query = "SELECT l FROM Lancamento l WHERE l.datalancamento = :datalancamento"), @NamedQuery(name = "Lancamento.findByFormapg", query = "SELECT l FROM Lancamento l WHERE l.formapg = :formapg"), @NamedQuery(name = "Lancamento.findByReservaestadia", query = "SELECT l FROM Lancamento l WHERE l.reservaestadia = :reservaestadia")})
public class Lancamento implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "Id_lancamento")
    private Integer idlancamento;
    @Column(name = "Valor_total")
    private Float valortotal;
    @Column(name = "Data_lancamento")
    @Temporal(TemporalType.DATE)
    private Date datalancamento;
    @Column(name = "Forma_pg")
    private String formapg;
    @Cascade({
        CascadeType.SAVE_UPDATE,
        CascadeType.PERSIST
    })
    @OneToOne(optional = false, fetch = FetchType.LAZY)
    @JoinColumn(name = "Id_reserva", insertable = true, updatable = true, nullable = false)
    private ReservaEstadia reservaEstadia;

    public Lancamento() {
    }

    public Lancamento(Integer idlancamento) {
        this.idlancamento = idlancamento;
    }

    public Integer getIdlancamento() {
        return idlancamento;
    }

    public void setIdlancamento(Integer idlancamento) {
        this.idlancamento = idlancamento;
    }

    public Float getValortotal() {
        return valortotal;
    }

    public void setValortotal(Float valortotal) {
        this.valortotal = valortotal;
    }

    public Date getDatalancamento() {
        return datalancamento;
    }

    public void setDatalancamento(Date datalancamento) {
        this.datalancamento = datalancamento;
    }

    public String getFormapg() {
        return formapg;
    }

    public void setFormapg(String formapg) {
        this.formapg = formapg;
    }

    public ReservaEstadia getReservaEstadia() {
        return reservaEstadia;
    }

    public void setReservaEstadia(ReservaEstadia reservaEstadia) {
        this.reservaEstadia = reservaEstadia;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idlancamento != null ? idlancamento.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Lancamento)) {
            return false;
        }
        Lancamento other = (Lancamento) object;
        if ((this.idlancamento == null && other.idlancamento != null) || (this.idlancamento != null && !this.idlancamento.equals(other.idlancamento))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.reservasis.Lancamento[idlancamento=" + idlancamento + "]";
    }
}
